# Filename: contacts.py

class Person:
    def __init__(self, name, email, addr, tel):
        '''Initializes the person's information'''
        self.name = name;
        self.email = email;
        self.addr = addr;
        self.tel = tel;
        
    def __def__(self):
        ''' I am dying'''
        pass;
    
    def printinfo(self):
        print 'NAME:', self.name;
        print 'E-mail:', self.email;
        print 'Address', self.addr;
        print 'TEL:', self.tel;
        
    def updata_email(self, email):
        self.email  = email;
        
    def updata_addr(self, addr):
        self.addr = addr;
        
    def updata_tel(self, tel):
        self.tel = tel;

    def fname(self):
        return self.name;

p = Person('jomie', 'welcome@ucweb.com', "uc", 1528888);
p2 = Person('uc', 'jomie@ucweb.com', 'ucbaba', 1233555);
        
import cPickle as q
'''
outdictory = 'dictory.txt';
f2 = file(outdictory, 'w');
Dic = {p.fname():p};
D = {p2.fname:p2};
q.dump(Dic, f2);
q.dump(D, f2);
f2.close();

f2 = file(outdictory, 'r');
dic = q.load(f2);
f2.close();

for name, p in dic.items():
    p.printinfo();
    print;
'''
running = True;
operationType = 0;


Dic = {};
outdictory = 'dictory.txt';

while running:
    print "1 for adding"
    print "2 for updating"
    print "3 for deleting"
    print "4 for searching"
    print "5 for closing your contaction book"

    operationType = int(raw_input( "Enter Your Operation Types:\n "));
    if operationType == 1:
        '''for adding'''
        name = raw_input('enter name: \n');
        email = raw_input('enter email:\n');
        address = raw_input('enter address:\n');
        tel = raw_input('enter telphone number:\n');
        person = Person(name, email, address, tel);
        Dic[person.fname()] = person;
        f2 = file(outdictory, 'w');
        q.dump(Dic, f2);
      
        f2.close();
                        
    elif operationType == 2:
        #for updating friends information
        pass
    elif operationType == 3:
        #for deleting someone information;
        pass
    elif operationType == 4:
        ''' for seaching '''
        name = raw_input('Enter your name for searching:\n');
        f2 = file(outdictory, 'r');
        dic = q.load(f2);
        f2.close();
        print name;
        dic[name].printinfo();
        
    else:
        running = False;
                






